
package com.yb.guigu.pick.activity.listener.redis;

import com.yb.guigu.pick.activity.annotation.RedisStreamListener;
import com.yb.guigu.pick.activity.channel.IRedisChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.RecordId;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/7/14 13:25
 * FileName: DemoRedisStreamListener
 * Description:
 */

@Slf4j
@Component
@RedisStreamListener(streamKey = "stream:demo", timeout = 0L,group = "stream:demo",consumer = "demo1")
public class DemoRedisStreamListener2 extends RedisStreamConsumer<DemoRedisStreamListener2> {


    @Override
    public void onMessage(IRedisChannel redisChannel, MapRecord<String, String, String> message) {
        Map<String, String> value = message.getValue();
        String stream = message.getStream();
        RecordId id = message.getId();
        log.info("{}",value);
        log.info("{}",stream);
        log.info("{}",id);
        redisChannel.ack();
    }
}
